package com.example.anliku.controller;

import com.example.anliku.entity.Message;
import com.example.anliku.entity.Admin;
import com.example.anliku.service.AdminService;
import com.example.anliku.service.ElasticSearchService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Api(tags = "管理员模块")
@RestController
@RequestMapping("/api/admin")

public class AdminController {
    @Resource
    private AdminService adminService;

    @ApiOperation(value = "管理员登录")
    @PostMapping(value = "/login")
    public Message login(String adminId ,String adminPwd){
        return adminService.selectAllByAdminIdAndAdminPwd(adminId, adminPwd);
    }

    @ApiOperation(value = "管理员注册")
    @PostMapping(value = "/register")
    public Message register(Admin admin){
        return adminService.insertSelective(admin);
    }

    @ApiOperation(value = "管理员密码修改，状态修改")
    @PostMapping(value = "/put")
    public Message put(String adminId,String adminPwd,String adminState){
        return adminService.updateAdminPwdByAdminId(adminPwd,adminId,adminState);
    }

    @ApiOperation(value = "管理员删除")
    @DeleteMapping(value = "/delete")
    public Message delete(String adminId){
        return adminService.deleteByPrimaryKey(adminId);
    }

    @ApiOperation(value = "根据adminId查询管理员信息")
    @GetMapping(value = "/get")
    public Message get(String adminId){
        return adminService.selectByPrimaryKey(adminId);
    }

    @ApiOperation(value = "查询全部管理员信息")
    @GetMapping(value = "/all")
    public Message all(){
        return adminService.selectAll();
    }


}
